package rs.etf.es.algorithm;

import java.io.Serializable;
import java.util.HashMap;

public class PiMessages implements Serializable {

    private HashMap<String, HashMap<String, Double>> piMessages;

    public PiMessages() {
	piMessages = new HashMap<String, HashMap<String, Double>>();
    }

    public void putPiMessage(String sentFrom, String forVariable, Double valueOfPiMsg) {
	HashMap<String, Double> variablesMap = piMessages.get(sentFrom);
	if (variablesMap == null) {
	    variablesMap = new HashMap<String, Double>();
	    piMessages.put(sentFrom, variablesMap);
	}
	variablesMap.put(forVariable, valueOfPiMsg);
    }

    public Double getPiMessage(String sentFrom, String forVariable) {
	HashMap<String, Double> variablesMap = piMessages.get(sentFrom);
	if (variablesMap != null) {
	    return variablesMap.get(forVariable);
	} else {
	    return null;
	}
    }

}
